package dp.gr03.payroll.affiliationTransactions;

import dp.gr03.payroll.affiliations.NoAffiliation;
import dp.gr03.payroll.affiliations.UnionAffiliation;
import dp.gr03.payroll.payrollDatabase.PayrollDatabase;
import dp.gr03.payroll.payrollDomain.Affiliation;
import dp.gr03.payroll.payrollDomain.Employee;

public class ChangeUnaffiliatedTransaction extends ChangeAffiliationTransaction
{
    
    public ChangeUnaffiliatedTransaction(int empID){
        super(empID);
    }

    @Override
    public Affiliation getAffiliation()
    {
        return new NoAffiliation();
    }

    @Override
    public void recordMembership(Employee e)
    {
        Affiliation af = e.getAffiliation();
        if(af instanceof UnionAffiliation){
            UnionAffiliation uf = (UnionAffiliation)af;
            int memberId = uf.getMemberId();
            PayrollDatabase.getInstance().deleteUnionMember(memberId);
        }
        
    }

}
